#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    cin >> n;
    int neg = 0;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      if (x < 0) {
        neg++;
        a[i] = -x;
      } else
        a[i] = x;
    }
    for (int i = 0; i < neg; ++i) {
      a[i] = -a[i];
    }

    cout << (is_sorted(a, a + n) ? "YES\n" : "NO\n");
  }
}
